import { exportUrl } from "@/api/report/mesWaitPickOrderMaterials";
import {
  getLineCodeList, //查询线体
} from "@/api/employee/mesUserExtend";
import url from "@/axios/url";
const { mesUrl } = url();
let vm = null;
const sendThis = (_this) => {
  vm = _this;
};
export { sendThis };
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", // 点击时返回的标识
    url: exportUrl,
    // auth: "auth:operlog:export", //权限字段
  },
];
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail", // 点击时返回的标识
  },
];
// 搜索条件配置
export const searchConfig = {
  data () {
    const self = this;
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          orderNo: {
            type: "input",
            label: $i18n.t("mesWaitPickOrderMaterials.orderNo"),
          },
          planCode: {
            type: "input",
            label: $i18n.t("mesWaitPickOrderMaterials.planCode"),
          },
          orderCode: {
            type: "input",
            label: $i18n.t("mesWaitPickOrderMaterials.orderCode"),
          },
          materialCode: {
            type: "input",
            label: $i18n.t("mesWaitPickOrderMaterials.prodCode"),
          },
          materialName: {
            type: "input",
            label: $i18n.t("mesWaitPickOrderMaterials.prodName"),
          },
          pickTime: {
            type: "datetimerange",
            label: $i18n.t("mesWaitPickOrderMaterials.pickTime"),
            attrs: {
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              searchArrKey: ["pickTimeMin", "pickTimeMax"],
            },
          },
          returnWorkCellName: {
            type: "input",
            label: $i18n.t("mesWaitPickOrderMaterials.returnWorkCellName"),
          },
          workshopCode: {
            label: $i18n.t("common.workshopName"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const params = {
                modelingCode: self.$store.getters.factoryCode,
                level: 4,
                modelingType: "0",
              };
              const list = await getLineCodeList(params);
              return list.data.result;
            },
          },
          lineCode: {
            label: $i18n.t("common.line"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName"
            },
            optionsLinkageFields: ["workshopCode"],
            options: async (data) => {
              const params = {
                modelingCode: data.workshopCode,
                level: 5,

              };
              const list = await getLineCodeList(params);
              return list.data.result;
            },
          },
          warehouseCode: {
            label: $i18n.t("mesWaitPickOrderMaterials.warehouseCode"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const params = {
                modelingCode: self.$store.getters.factoryCode,
                level: 4,
                modelingType: "1",
              };
              const list = await getLineCodeList(params);
              return list.data.result;
            },
          },
        },
      },
    };
  },
};
